package com.ht.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.ht.dto.Patient;
import com.ht.mapper.PatientMapper;
import com.ht.service.IPatientService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 代齐园
 * @since 2022-05-25
 */
@Service
public class PatientServiceImpl extends ServiceImpl<PatientMapper, Patient> implements IPatientService {

    @Resource
    private PatientMapper patientMapper;

    @Override
    public List<Patient>  getPatient(Long id) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("user_id",id);//根据当前登录用户的id查询
        List<Patient> list = patientMapper.selectList(queryWrapper);
        return list;
    }

    @Override
    public void insertPatient(Long id, Patient patient) {
        patient.setUserId(id);//将登录用户的id传入到患者信息中
        patientMapper.insert(patient);
    }

    @Override
    public void updatePatient(Patient patient) {
        patientMapper.updateById(patient);
    }

    @Override
    public void deletePatient(Long id) {
        patientMapper.deleteById(id);
    }
}